- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.9k
 
fix: add shorthand record field completions #20831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add shorthand record field completions #20831
Conversation
9469076    to
    6c29055      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was always annoyed by this, thanks! Just one nit.
| let field_name = field.name(ctx.db); | ||
| 
               | 
          ||
| if let Some(local) = ctx.locals.get(&field_name) | ||
| && local.ty(ctx.db) == field.ty(ctx.db).to_type(ctx.db) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit better to use could_unify_deeply(), I believe, although I won't hold strong on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be Type::could_unify_with_deeply, right
Example
---
```rust
struct Foo { bar: bool, n: i32 }
fn baz() {
    let bar = true;
    let foo: Foo = Fo$0;
}
```
**Before this PR**:
```rust
struct Foo { bar: bool, n: i32 }
fn baz() {
    let bar = true;
    let foo: Foo = Foo { bar: ${1:()}, n: ${2:()} }$0;
}
```
**After this PR**:
```rust
struct Foo { bar: bool, n: i32 }
fn baz() {
    let bar = true;
    let foo: Foo = Foo { bar$1, n: ${2:()} }$0;
}
```
    6c29055    to
    9a9f011      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Add shorthand field completion for record-expr
Close #20830
Example
Before this PR:
After this PR: